package com.neu.web.controller.system;


import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neu.common.annotation.Log;
import com.neu.common.core.controller.BaseController;
import com.neu.common.core.domain.AjaxResult;
import com.neu.common.enums.BusinessType;
import com.neu.system.domain.NeuAirType;
import com.neu.system.service.INeuAirTypeService;
import com.neu.common.utils.poi.ExcelUtil;
import com.neu.common.core.page.TableDataInfo;

/**
 * 空气质量数据Controller
 *
 */
@RestController
@RequestMapping("/system/type")
public class NeuAirTypeController extends BaseController
{
    @Autowired
    private INeuAirTypeService neuAirTypeService;

    /**
     * 查询空气质量类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(NeuAirType neuAirType)
    {
        startPage();
        List<NeuAirType> list = neuAirTypeService.selectNeuAirTypeList(neuAirType);
        return getDataTable(list);
    }

    /**
     * 导出空气质量信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:export')")
    @Log(title = "导出空气质量信息列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NeuAirType neuAirType)
    {
        List<NeuAirType> list = neuAirTypeService.selectNeuAirTypeList(neuAirType);
        ExcelUtil<NeuAirType> util = new ExcelUtil<NeuAirType>(NeuAirType.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取空气质量信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(neuAirTypeService.selectNeuAirTypeById(id));
    }

    /**
     * 新增空气质量信息
     */
    @PreAuthorize("@ss.hasPermi('system:type:add')")
    @Log(title = "新增空气质量信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NeuAirType neuAirType)
    {
        return toAjax(neuAirTypeService.insertNeuAirType(neuAirType));
    }

    /**
     * 修改空气质量信息
     */
    @PreAuthorize("@ss.hasPermi('system:type:edit')")
    @Log(title = "修改空气质量信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NeuAirType neuAirType)
    {
        return toAjax(neuAirTypeService.updateNeuAirType(neuAirType));
    }

    /**
     * 删除空气质量信息
     */
    @PreAuthorize("@ss.hasPermi('system:type:remove')")
    @Log(title = "删除空气质量信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(neuAirTypeService.deleteNeuAirTypeByIds(ids));
    }
}

